package com.example.webmagicdemo;

import cn.hutool.core.date.DateUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Description 延时
 * @Date 2024/9/24 15:27
 **/
@Slf4j
@RestController
@RequestMapping("/sleep")
public class SleepController {

    @PostMapping("/t1")
    public String test() throws InterruptedException {
        String start = DateUtil.now();
        try {
            Thread.sleep(5000);
        }catch (Exception e){
            e.printStackTrace();
        }finally {
            // 打印接口开始执行的时间和当前时间
            log.info("start:" + start + ", now:" + DateUtil.now());
        }
        return "end";
    }
}
